package com.study.service.impl;

import com.study.mapper.EchartsMapper;
import com.study.model.EchartsRoleUser;
import com.study.service.EchartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author king james
 * @create 2021-09-13-{TIME}
 */
@Service
public class EchartServiceImp implements EchartService {
    @Autowired
    private EchartsMapper echartsMapper;

    @Override
    public int queryUserCount() {
        return echartsMapper.queryUserCount();
    }

    @Override
    public int queryRoleCount() {
        return echartsMapper.queryRoleCount();
    }

    @Override
    public int queryResourcesCount() {
        return echartsMapper.queryResourcesCount();
    }

    @Override
    public int queryLogCount() {
        return echartsMapper.queryLogCount();
    }

    /**
     * 统计各类角色的比例
     * @return
     */
    @Override
    public EchartsRoleUser roleUserCount() {
        EchartsRoleUser echartsRoleUser = new EchartsRoleUser();
        echartsRoleUser.setAdmin(echartsMapper.RoleUserCount(1));//管理员
        echartsRoleUser.setOrdinaryUser(echartsMapper.RoleUserCount(2));//普通用户
        echartsRoleUser.setSuperAdmin(echartsMapper.RoleUserCount(3));//成绩管理员
        echartsRoleUser.setStudent(echartsMapper.RoleUserCount(4));//学生
        echartsRoleUser.setTeacher(echartsMapper.RoleUserCount(5));//老师
        echartsRoleUser.setHeadmaster(echartsMapper.RoleUserCount(6));//校长
        echartsRoleUser.setBackEnd(echartsMapper.RoleUserCount(7));//前端
        echartsRoleUser.setFrontEnd(echartsMapper.RoleUserCount(8));//前端
        return echartsRoleUser;
    }
}
